package recursion;

public class BubbleSearchBasic {
    public static void bubbleSearchBasic(int[] arr) {
        recursionBubbleSearch(arr,arr.length-1);
    }

    /**
     * 递归冒泡排序数组
     * @param arr 待排序数组
     * @param high 数组的末尾元素
     */
    public static void recursionBubbleSearch(int[] arr, int high) {
        if (high == 0) {
            return;
        }
        for (int low = 0; low < high; low++) {
            if (arr[low] > arr[low + 1]) {
                int temp = arr[low];
                arr[low] = arr[low + 1];
                arr[low + 1] = temp;
            }
        }
        recursionBubbleSearch(arr, high - 1);
    }


}
